package io.awen.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName FileProperties
 * @Description 文件参数配置
 * @Author gel
 * @Date 2021-01-22
 **/
@Data
@Configuration
@ConfigurationProperties(prefix = "file")
public class FileConfig {

    /** 文件大小限制 */
    private Long maxSize;

    /** 头像大小限制 */
    private Long avatarMaxSize;

    private FilePath mac;

    private FilePath linux;

    private FilePath windows;

    private String sourceAddress;

    public FilePath getPath(){
        String os = System.getProperty("os.name");
        if(os.toLowerCase().startsWith("win")) {
            return windows;
        } else if(os.toLowerCase().startsWith("mac")){
            return mac;
        }
        return linux;
    }

    @Data
    public static class FilePath {

        private String root;

        private String path;

        private String avatar;
    }
}
